<!--
 * @Author: xjt
 * @Date: 2021-06-24 23:05:13
 * @LastEditTime: 2021-06-29 16:04:39
 * @Description: 全市集中隔离场所工作人员
 * @LastEditors: cqg
-->
<template>
	<basic-container v-loading="loading" element-loading-text="数据加载中...">
		<el-date-picker value-format="yyyy-MM-dd HH:mm:ss" v-model="useStartTime" type="datetime" placeholder="选择日期时间">
		</el-date-picker>
		<!-- <input type="text" v-model="useStartTime" /> -->
		<el-button @click="search()" type="primary">搜索</el-button>
		<el-button @click="download()" type="primary">导出</el-button>
		<el-table :data="tableData" style="width: 100%" ref="multipleTable" id="out-table">
			<el-table-column prop="statisticTime" label="日期" width="80">
			</el-table-column>
			<el-table-column label="基本数">
				<el-table-column prop="csCount" label="场所底数" width="90">
				</el-table-column>
				<el-table-column prop="smCount" label="应扫码从业人员底数" width="90">
				</el-table-column>
			</el-table-column>
			<el-table-column label="核酸检测情况">
				<el-table-column prop="hsCount" label="近3天从业人员核酸检测累计数" width="90">
				</el-table-column>
				<el-table-column prop="hsScale" label="近3天从业人员核酸检测比例" width="90">
				</el-table-column>
			</el-table-column>
			<el-table-column label="疫苗接种情况">
				<el-table-column prop="fristneedleCount" label="新冠疫苗接种第1剂人数" width="90">
				</el-table-column>
				<el-table-column prop="fristneedleScale" label="新冠疫苗接种第1剂比例" width="90">
				</el-table-column>
				<el-table-column prop="secondneedleCount" label="新冠疫苗接种第2剂人数" width="90">
				</el-table-column>
				<el-table-column prop="secondneedleScale" label="新冠疫苗接种第2剂比例" width="90">
				</el-table-column>
			</el-table-column>
		</el-table>
	</basic-container>
</template>

<script>
	import {
		queryAll,
		exportAll
	} from "@/views/yq-totalSearch/api/personnel.js";
	export default {
		data() {
			return {
				// 页面loading
				loading: false,
				tableData:[],
				useStartTime:'',
				pickerOptions: {
					shortcuts: [{
						text: '今天',
						onClick(picker) {
							picker.$emit('pick', new Date());
						}
					}, {
						text: '昨天',
						onClick(picker) {
							const date = new Date();
							date.setTime(date.getTime() - 3600 * 1000 * 24);
							picker.$emit('pick', date);
						}
					}, {
						text: '一周前',
						onClick(picker) {
							const date = new Date();
							date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
							picker.$emit('pick', date);
						}
					}]
				},
				value1: '',
				value2: '',
				value3: ''
			}
		},
		created() {
			queryAll()
				.then(res => {
					console.log(res)
					this.tableData = res.data.data;
					console.log(this.tableData)
				})
				.finally(() => {
					this.loading = false;
				});
			// },
		},
		methods: {
			search() {
				let useStartTime = this.useStartTime;
				// let jsonObj = JSON.parse(useStartTime);
				// console.log(jsonObj)
				let date = new Date();
				
				let year = date.getFullYear(); //年 ,从 Date 对象以四位数字返回年份
				let month = date.getMonth() + 1; //月 ,从 Date 对象返回月份 (0 ~ 11) ,date.getMonth()比实际月份少 1 个月
				let day = date.getDate(); //日 ,从 Date 对象返回一个月中的某一天 (1 ~ 31)
				
				let hours = date.getHours(); //小时 ,返回 Date 对象的小时 (0 ~ 23)
				let minutes = date.getMinutes(); //分钟 ,返回 Date 对象的分钟 (0 ~ 59)
				let seconds = date.getSeconds(); //秒 ,返回 Date 对象的秒数 (0 ~ 59)   
				
				//获取当前系统时间  
				let currentDate = year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
				if (useStartTime > currentDate) {
					this.$message.error("时间不能超过当前时间")
				}else if (useStartTime.length == 0) {
					this.$message.error("请输入搜索时间")
				} else {
					// debugger
					let params = {useStartTime:this.useStartTime};
					// console.log(params)
					queryAll(params)
						.then(res => {
							// debugger
							console.log(res)
							this.tableData = res.data.data.records;
						})
						.finally(() => {
							this.loading = false;
						});
				}
			},
			download() {
				this.publicExport(
					'xzczxdddc',
					'/statistical/export/staffHealth', {},
					'xls',
					'get'
				);
			}
		}
	}
</script>

<style lang="scss" scoped>
	.el-input {
		width: 30%;
		padding: 20px;
	}
</style>
